# Copyright 2009 http://www.yuntien.com
# Licensed under the Apache License, Version 2.0

from google.appengine.ext import webapp
from google.appengine.api import users
from ytblog.model.tag import *
from ytblog.controller.common import *
    
class BlogAdminController(BlogController):

  def render(self, context):
    path = os.path.join(os.path.dirname(__file__), ytblog.config.TEMPLATE_DIR + 'admin.html')
    self.response.out.write(template.render(path, context)) 
    
  def get(self):
    if not users.is_current_user_admin():
      self.response.out.write('No authorization...')
      return      
      
    context = { }
    self.add_common_context(context)
    self.render(context)

  def post(self):
    if not users.is_current_user_admin():
      self.response.out.write('No authorization...')
      return      
      
    tag = TagInfo.get_or_insert_by_name(self.request.get('tags'), name=self.request.get('tags'))
    tag.put()  
    self.redirect('/')  
    